import Vue from 'vue'
import loadingcmp from './loading.vue'
//定义一个加载组件
//插件
function createComponentLoadingPlugin(Vue){
    //创建一个子对象 继承Vue 对象
    let LoadingComponent = Vue.extend(loadingcmp)
    function loading(msg = '加载中。。。'){
        let div = document.createElement('div')
        div.id = 'loading'
        document.body.appendChild(div)
        new LoadingComponent({
            props:{
                msg:{
                    type:String,
                    default:msg
                }
            }
        }).$mount('#loading')
        return ()=> document.body.removeChild(document.querySelector('#loading'))
    }
    Vue.prototype.$loading = loading
}
Vue.use(createComponentLoadingPlugin)